package com.laopan.wxpay.config;

import com.laopan.wxpay.paycallback.PayCallBack;
import com.laopan.wxpay.request.close.OrderClose;
import com.laopan.wxpay.request.prepay.JsapiPrepay;
import com.laopan.wxpay.request.query.MchOrderIdQuery;
import com.laopan.wxpay.request.query.RealQueryOrder;
import com.laopan.wxpay.request.query.WxOrderIdQuery;
import com.laopan.wxpay.request.refund.DomesticRefund;
import com.laopan.wxpay.request.refund.RefundQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author laopan
 * @date 2021/4/5 0005 16:25
 */
@Configuration
@EnableConfigurationProperties(WxPayConfig.class)
@ConditionalOnProperty(prefix = "pay.wx",name="enable",havingValue = "true")
public class WxpayRegister {
    @Autowired
    private WxPayConfig wxPayConfig;
    @Bean
    public OrderClose orderClose(){
        return new OrderClose(wxPayConfig);
    }
    @Bean
    public RealQueryOrder realQueryOrder(){
        return new RealQueryOrder(wxPayConfig);
    }
    @Bean
    public MchOrderIdQuery mchOrderIdQuery(RealQueryOrder realQueryOrder){
        return new MchOrderIdQuery(realQueryOrder);
    }
    @Bean
    public WxOrderIdQuery wxOrderIdQuery(RealQueryOrder realQueryOrder){
        return new WxOrderIdQuery(realQueryOrder);
    }
    @Bean
    public JsapiPrepay jsapiPrepay(){
        return new JsapiPrepay(wxPayConfig);
    }
    @Bean
    public DomesticRefund domesticRefund(){
        return new DomesticRefund(wxPayConfig);
    }
    @Bean
    public RefundQuery refundQuery(){
        return new RefundQuery(wxPayConfig);
    }
    @Bean
    public PayCallBack payCallBack(){
        return new PayCallBack(wxPayConfig);
    }
}
